﻿using Common;
using Common.DataModels;

namespace PLC.Domain.Entity;
/// <summary>
/// 状态数据
/// </summary>
public class DeviceStatus:AggregateRoot
{
    /// <summary>
    /// 设备id
    /// </summary>
    public long DeviceId { get;  set; }
    /// <summary>
    /// 寄存器位
    /// </summary>
    public string Register { get;  set; }
    /// <summary>
    /// 数据类型
    /// </summary>
    public int DataType { get;  set; }
    /// <summary>
    /// 数据值
    /// </summary>
    public string RegisterValue { get; set; }
    /// <summary>
    /// 值描述
    /// </summary>
    public string Description { get;  set; }
    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreateTime { get;  set; }
    /// <summary>
    /// 是否删除
    /// </summary>
    public bool IsDelete { get;  set; }
    public DeviceStatus() { }
    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="deviceId">设备id</param>
    /// <param name="register">寄存器</param>
    /// <param name="dataType">数据类型</param>
    /// <param name="registerValue">寄存器值</param>
    /// <param name="description">值的描述</param>
    /// <param name="creatorId">创建人</param>
    public DeviceStatus(long deviceId,string register,int dataType,string registerValue,string description)
    {
        this.SetDeviceId(deviceId).SetRegister(register).SetDataType(dataType).SetRegisterValue(registerValue)
            .SetDescription(description).Build();
    }

    public DeviceStatus  Build()
    {
        this.Id = SnowflakeHelper.GetId();
        this.IsDelete = false;
        this.CreateTime = DateTime.Now;
        return this;
    }
    public DeviceStatus SetIsDelete(bool isDelete)
    {
        this.IsDelete = isDelete;
        return this;
    }

    public DeviceStatus SetDeviceId(long deviceId)
    {
        this.DeviceId = deviceId;
        return this;
    }

  

    public DeviceStatus SetRegister(string register)
    {
        this.Register = register;
        return this;
    }

    public DeviceStatus SetDataType(int dataType)
    {
        this.DataType = dataType;
        return this;
    }

    public DeviceStatus SetRegisterValue(string registerValue)
    {
        this.RegisterValue = registerValue;
        return this;
    }

    public DeviceStatus SetDescription(string description)
    {
        this.Description = description;
        return this;
    }
}